package com.tvein.sanguo.character.view
{
	//flash
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.mediator.FlashMediator;
	//custom
	import com.tvein.sanguo.character.common.GameConstants;
	import com.tvein.sanguo.character.model.SystemProxy;
	import com.tvein.sanguo.Character;
	import com.tvein.sanguo.swc.character.CharacterShell;
//
	public class CharacterMediator extends FlashMediator
	{
		static public const NAME : String = "CharacterMediator";
		
		public function CharacterMediator(viewComponent:Object)
		{
			super(NAME, viewComponent);
		}
		
		public function get character() : Character
		{
			return viewComponent as Character;
		}
		
		//Custom
		private var systemData:SystemProxy;
		
		public var characterShell:CharacterShell;
		
		override public function onRegister() : void
		{
			systemData = facade.retrieveProxy(SystemProxy.NAME) as SystemProxy;
			
			character.visible = false;
			
			characterShell = new CharacterShell(systemData.config);
			
			character.addChild(characterShell);
			
			characterShell.addEventListener("CharacterShell", _handleEvents);
		}
		
		private function _handleEvents(evt:Object):void
		{
			if (evt.cmd[0] == "-roleDetail")
			{
				routeNotification(GameConstants.MODULE_INVOKE, ["-role", ["roleDetail"]], null, GameConstants.MODULE_ACTION + "/*");
			}
		}
	}
}